<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <title>升级收费专家</title>


    <!-- Expand styles -->
    <link href="../css/app/app.css" rel="stylesheet">
    <link href="../css/app/default.css" rel="stylesheet">
    <link href="../css/mui/mui.css" rel="stylesheet">


    <!-- Custom styles for this template -->
    <!-- <link href="../css/iOS/mobile/mobile.css" rel="stylesheet"> -->
</head>

<body>

    <!-- header -->
    <div>
        <div class="widget-default margin-b-3 widget-body">
            <span class="font-17 black">升级为收费专家条件</span>
        </div>
        <div class="widget-default margin-b-10 widget-body padding-t-40  text-center" id="auditDiv"
            style="display: none;">
            <div id="auditStatus"></div>
            <p class="font-14 gray padding-t-20 elli2" id="auditDesc">
            </p>
        </div>

        <!--  -->
        <div class="widget-default margin-b-3 widget-body">
            <div class="display-flex align-items-center justify-content-between width-100 padding-l-10">
                <div class="display-flex flex-column justify-content-between">
                    <p class="font-weight black font-17 font-weight no-margin">回复量需达到<span class="orange1"
                            id="value0"></span>条
                    </p>
                    <span class="gray font-14 padding-t-10">你目前回复量<span id="num0"></span>条</span>
                </div>
                <div class="farm-label text-center margin-t-5" id="btn0" onclick="toFinish(0)">
                </div>
            </div>
        </div>
        <!--  -->
        <div class="widget-default margin-b-3 widget-body">
            <div class="display-flex align-items-center justify-content-between width-100 padding-l-10">
                <div class="display-flex flex-column justify-content-between">
                    <p class="font-weight black font-17 font-weight no-margin">学员数需达到<span class="orange1"
                            id="value1"></span>人
                    </p>
                    <span class="gray font-14 padding-t-10">你目前有<span id="num1"></span>人</span>
                </div>
                <div class="farm-label text-center margin-t-5" id="btn1" onclick="toFinish(1)">
                </div>
            </div>
        </div>
        <!--  -->
        <div class="widget-default margin-b-3 widget-body">
            <div class="display-flex align-items-center justify-content-between width-100 padding-l-10">
                <div class="display-flex flex-column justify-content-between">
                    <p class="font-weight black font-17 font-weight no-margin">专家文献需达到<span class="orange1"
                            id="value2"></span>篇
                    </p>
                    <span class="gray font-14 padding-t-10">你目前有<span id="num2"></span>篇</span>
                </div>
                <div class="farm-label text-center margin-t-5" id="btn2" onclick="toFinish(2)">
                </div>
            </div>
        </div>
        <div class="save-btn-charge margin-t-50" id="btn_update" onclick="update()">

        </div>

        <p class="font-12 gray text-center p-fixed">如有疑问，请添加微信号：nkzjfw咨询</p>
    </div>


    <script src="../js/dsbridge.js"></script>
    <script src="../js/jquery.js"></script>
    <script src="../js/mui/mui.js"></script>
    <script src="../js/mui/mui.picker.min.js"></script>
    <script src="../js/layer.js"></script>
    <script src="../js/app/app-base.js"></script>
    <script src="../js/app/app-url.js"></script>
    <script src="../js/app/app-ajax.js"></script>
    <script>
        var isUpdate = false;

        $(document).ready(function () {
            var data = {
                userAccId: getUserId()
            }
            getServerData(url_getUpgradeCondition, data);
        })

        function getServerDataSuccess(url, data) {
            switch (url) {
                case url_getUpgradeCondition:
                    setView(data);
                    break;
                case url_saveUpgrade:
                    showAlertClose("申请成功");
                    break;
            }
        }

        function setView(data) {
            var list = data.data;
            isUpdate = true;

            var clz = '<a class="white font-12 charge-bg">去完成</a>';
            var clz2 = '<a class="orange2 font-12 charge-bg1">已完成</a>';

            for (var i = 0; i < list.length; i++) {

                $("#value" + i).html(list[i].value);
                $("#num" + i).html(list[i].differNum);

                if (list[i].value > list[i].differNum) {
                    isUpdate = false;
                    $("#btn" + i).html(clz);
                } else {
                    $("#btn" + i).html(clz2);
                }

            }

            if (data.auditStatus == "1") {
                $("#auditDiv").show();
                $("#auditStatus").html('<img class="charge-img" src="../img/going.png" alt="">');
            } else if (data.auditStatus == "2") {
                $("#auditDiv").show();
                $("#auditStatus").html('<img class="charge-img" src="../img/success.png" alt="">');
            } else if (data.auditStatus == "3") {
                $("#auditDiv").show();
                $("#auditDesc").html(data.auditDesc);
                $("#auditStatus").html('<img class="charge-img" src="../img/fail.png" alt="">');
            }

            var btn1 =
                '<button type="button" class="mui-btn mui-btn-primary mui-btn-block charge-bg1 orange2">未达标</button>';
            var btn2 = '<button type="button" class="mui-btn mui-btn-primary mui-btn-block charge-bg">升级</button>';

            if (!isUpdate) {
                $("#btn_update").html(btn1);
            } else {
                $("#btn_update").html(btn2);
            }
        }

        function update() {
            if (isUpdate) {
                var data = {
                    userAccId: getUserId()
                }
                getServerData(url_saveUpgrade, data);
            }
        }

        function toFinish(type) {
            dsBridge.call("toFinish", type);
        }
    </script>

</body>

</html>